$(document).ready(getList);

function getList() {
	
	var html="";
	
	for (var i = 0, t = localStorage.length; i < t; i++) {
		
		key = localStorage.key(i);
		
		if(key!="id"){	
			
			task=JSON.parse(localStorage[key]);

			title=task[0];
			descript=task[1];
			priority=task[2];			
			due=task[3];
			var img="green_button.png";
			if(priority==="High"){
				img="red_button.png";
			}else if(priority==="Medium"){
				img="orange_button.png";
			}
			
			html+='<li class="task">'+

                        '<div class="taskInfo">'+
                            '<div class="taskPriority">'+
                                '<img src="img/'+img+'" />'+
                            '</div>'+
                            '<div class="taskTitle" contenteditable="true">'+
                                title+
                            '</div>'+
                            '<div class="taskDue">'+
                             	due+
                            '</div>'+
                        '</div>'+

                        '<div class="description">'+
                            '<div class="text">'+
                            	descript+
                            '</div>'+
                            '<div class="options">'+
                                '<div class="edit">'+
                                    '<img src="img/edit.png" />'+
                                '</div>'+
                                '<div class="delete">'+
                                    '<img src="img/trash_can.png" />'+
                                '</div>'+
                            '</div>'+
                        '</div>'+
                    '</li> \n';	
		}
		
		$("#taskList").html(html);
		
	}
}

